import 'dart:async';

import 'package:get/get.dart';
import 'package:hotpot/route/route_ext.dart';
import 'package:hotpot/route/routes.dart';

class TimeUtils {

  static Timer? _timer;

  static bool isStop = false;

  static void stop() {
    isStop = true;
    _timer?.cancel();
  }

  static void exitStop() {
    isStop = false;
    startWait();
  }

  static void startWait() {
    _timer?.cancel();
    if (isStop) return;
    _timer = Timer(const Duration(milliseconds: 1000 * 60 * 3), () {
      if (![Routes.splash, Routes.loginData, Routes.loginService].contains(Get.currentRoute)) {
        Routes.lock.pushNamed();
      }
    });
  }

}